﻿package ui;

import java.rmi.RemoteException;

import javax.swing.JLabel;

import javax.swing.JPasswordField;
import javax.swing.JTextField;

import vo.generalManager.LoginPanelVO;

import main.Main;


import components.MyButton;
import components.MyPanel;


public class LoginPanel extends MyPanel{
	
	private JLabel pleaselogin;
	private JLabel username;
	private JLabel password;
	private JTextField usernamefield;
	private JPasswordField passwordfield;
	private MyButton login;

	
	protected void initComponent() {
		pleaselogin = new JLabel("请登录：");
		username = new JLabel("登录名:");
		password = new JLabel("密码:");
		usernamefield = new JTextField();
		passwordfield = new JPasswordField();
		login = new MyButton("登录");
		
		pleaselogin.setBounds(20, 20, 100, 20);
		username.setBounds(45, 60, 70, 25);
		password.setBounds(45, 100, 70, 25);
		usernamefield.setBounds(120, 60, 120, 25);
		passwordfield.setBounds(120, 100, 120, 25);
		login.setBounds(40, 160, 80, 30);
		
		this.add(pleaselogin);
		this.add(username);
		this.add(password);
		this.add(usernamefield);
		this.add(passwordfield);
		this.add(login);
		
		login.setButtonAction("login");
	}


	@Override
	protected void updateVO() {
		LoginPanelVO lpvo=null;
		try {
			lpvo = Main.getLogic().getLpvo();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		lpvo.setPassword(passwordfield.getText());
		lpvo.setUsername(usernamefield.getText());
		try {
			Main.getLogic().setLpvo(lpvo);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		
	}

}
